
# 斐波那契数列
def create_num(n):
    a, b = 0, 1
    cur_num = 0
    while cur_num < n:
        yield a # 如果一个函数中有yied函数，那么这就是一个生成器模板
        a, b = b, a + b
        cur_num += 1
    return "...over..."
# 如果在调用的函数中有yied的时，不是调用函数，而是创建一个生成器对象
# 生成器是一种特殊的迭代器
obj = create_num(20)

# for i in obj:
#     print(i)

while True:
    try:
        ret = next(obj)
        print(ret)
    except Exception as e:
        print(e.value)
        break